<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="css/jquery-ui.css" />
<script type="text/javascript" src="js/jquery.js" charset="GBK"></script>
<script type="text/javascript" src="js/jquery-ui.js" charset="GBK"></script>
<script type="text/javascript">
	function split(obj){
		 return obj.split( /[\+\-\*\/,]\s*/ );
	}
	var values = ["aa","bb"] ; 
	$(document).ready(function(){
		try{
			$("#ap").autocomplete({
				source:function(req , res){
					res(values);
				},
				select: function( event, ui ) {
					try{
			          var terms = split( this.value );
			          //alert(terms) ;
			          // remove the current input
			          terms.pop();
			          // add the selected item
			          terms.push(ui.item.value );
			          // add placeholder to get the comma-and-space at the end
			          terms.push( "" );
			          this.value = this.value + ui.item.value  ;
					}catch(e){
						alert(e.message) ;
					}
			          return false;
			      },
			      focus: function() {return false;}
			}) ;
		}catch(e){
			alert(e.message) ;
		}
	}) ;
</script>
</head>
<body>
	<textarea rows="1" cols="100" id="ap"></textarea>
</body>
</html>